import os
import sys

if sys.platform == 'win32':

    for i in ('LANGUAGE','LC_ALL','LC_MESSAGES','LANG'):

        if os.environ.get(i):
            break
    else:

        try:
            import ctypes
        except ImportError:
            pass

        else:
            lcid_user = ctypes.windll.kernel32.GetUserDefaultLCID()

            lcid_system = ctypes.windll.kernel32.GetSystemDefaultLCID()
            if lcid_user != lcid_system:

                lcid = [lcid_user, lcid_system]
            else:
                lcid = [lcid_user]

            import locale
            lang = [locale.windows_locale.get(i) for i in lcid]

            lang = ':'.join([i for i in lang if i])
            
            if lang:
                os.environ['LANGUAGE'] = lang